<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Route::namespace('Api\V1')->prefix('v1')->group(function () {
    Route::post('wx-login', 'AuthController@wx_login');
    Route::post('wx-bind-login', 'AuthController@bind_login');
    Route::get('index', 'IndexController@index');
    Route::post('search', 'IndexController@search');
    Route::post('search-tip', 'IndexController@title_tip');

    Route::get('doc-index', 'DocController@index');
    Route::get('article-index', 'ArticleController@index');
    Route::get('doc-menu', 'DocController@menu');
    Route::get('article-menu', 'ArticleController@menu');
    Route::get('doc-page-info', 'DocController@page_info');
    Route::get('article-page-info', 'ArticleController@page_info');
    Route::get('member-index', 'MemberController@index');
    Route::get('wx-sing', 'PublicController@getWxSing');


    //share
    Route::get('share-card', 'ShareController@share_card');
    Route::post('share-change_theme', 'ShareController@change_theme');

    //****


    Route::middleware(['auth:api', 'scopes:wx-app'])->group(function () {

        Route::post('member-edit-intro', 'MemberController@edit_intro');
        Route::get("get_login_key", "MemberController@get_login_key");
        Route::get("consent_login", "MemberController@consent_login");

        //buy
        Route::post('buy', 'UserBuyController@buy');

        //follow
        Route::post('follow-user', 'FollowController@follow_user');
        Route::get('follow-liveroom', 'FollowController@follow_liveroom');
        Route::get('subscribe-channel', 'FollowController@subscribe_channel');
        Route::get('subscribe-doc', 'FollowController@subscribe_doc');
        Route::get('favorite-lecture', 'FollowController@favorite_lecture');
        Route::get('like-article', 'FollowController@like_article');

        Route::get('subscribe-doc-list', 'FollowController@subscribe_doc_list');//收藏列表
        Route::get('member-follows', 'FollowController@follows');
        Route::get('member-fans', 'FollowController@fans');


        //comment
        Route::post('add-comment', 'CommentController@add_comment');
        Route::get('comment-vote', 'CommentController@vote');
        Route::get('comment-list', 'CommentController@get_comment');


        //
        Route::get('user-listened', 'IndexController@user_listened');

        Route::get("member-order", "MemberController@order");
        Route::get("member-listened", "MemberController@listened");
        Route::post("member-feedback", "MemberController@feedback");

        //wallet
        Route::get("wallet", "WalletController@index");
        Route::get("wallet-log", "WalletController@wallet_log");
        Route::get("withdraw-log", "WalletController@withdraw_log");
        Route::post("withdraw", "WalletController@withdraw");

        //public
        Route::post('upload-image', 'PublicController@uploadImage');
        Route::post('article-upload-image', 'PublicController@articleContentUploadImage');
        Route::post('article-upload-video', 'PublicController@articleContentUploadVideo');


        //center

        Route::get('center-my-doc', 'CenterController@my_doc');
        Route::get('center-doc-articles', 'CenterController@doc_articles');

        Route::get('my-doc-del', 'DocEditController@del_doc');
        Route::get('my-doc-article-del', 'DocEditController@del_article');
        Route::get('edit-doc-index', 'DocEditController@index');
        Route::get('edit-doc-before', 'DocEditController@before_edit');
        Route::post('edit-doc-base', 'DocEditController@edit_base');
        Route::post('edit-doc-cover', 'DocEditController@edit_cover');

        Route::get("edit-doc-article-before", "DocEditController@before_edit_article");
        Route::post("edit-doc-article", "DocEditController@edit_article");



    });
});

//合作平台API
Route::namespace('Api\Open')->prefix('open')->group(function () {
    Route::get('login-qr-code', 'PublicController@getLoginQrCode');


    //需要登录API
    Route::middleware(['auth:api', 'scopes:web-open'])->group(function () {
        Route::get('index', 'IndexController@index');
        //文档
        Route::get('doc-list', 'DocsController@index');
        Route::get('doc-before_edit', 'DocsController@before_edit');
        Route::post('doc-edit_base', 'DocsController@edit_base');
        Route::get('doc-book', 'DocsController@edit_book');
        Route::get('doc-book-page', 'DocsController@get_page');
        Route::post('doc-add-page', 'DocsController@add_page');
        Route::post('doc-delete-page', 'DocsController@delete_page');
        Route::post('doc-save-content', 'DocsController@save_content');
        Route::post('doc-collect-url', 'DocsController@collectUrl');
        //素材管理
        Route::post('upload-image', 'MaterialController@uploadImage');
        Route::post('upload-audio', 'MaterialController@uploadAudio');
        Route::post('upload-video', 'MaterialController@uploadVideo');
        Route::get('material-list', 'MaterialController@index');

        Route::post('material-delete', 'MaterialController@delete');

        //财务管理
        Route::post('pay-invoice', 'PayController@invoice');
        Route::post('pay-transaction', 'PayController@transaction');
        Route::post('pay-withdraw_record', 'PayController@withdraw_record');

        //评论
        Route::get('comments', 'CommentController@index');

        Route::post('comment-manage', 'CommentController@manage');
        Route::post('comment-replay', 'CommentController@replay');

        //public
        Route::get("search-tag", 'PublicController@searchTag');


        //collect
        Route::post('collect-menu', 'CollectController@collect_menu');
        Route::post('collect-content', 'CollectController@collect_content');
    });
});